﻿
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

namespace Adalbertus.BudgetPlanner.Services.Dto
{
    public class BudgetPlanDto : IDto
    {
        public virtual int Id { get; set; }
        public virtual CashFlowTypeDto FlowType { get; set; }

        public virtual decimal Value
        {
            get
            {
                return Details.Sum(i => i.Value);
            }
        }

        private IList<BudgetPlanItemDto> _details;
        public virtual IList<BudgetPlanItemDto> Details
        {
            get
            {
                Contract.Ensures(Contract.Result<IList<BudgetPlanItemDto>>() != null);
                return _details;
            }
            set
            {
                Contract.Requires<ArgumentNullException>(value != null);
                _details = value;
            }
        }

        public BudgetPlanDto()
            : base()
        {
            _details = new List<BudgetPlanItemDto>();
        }
    }
}
